//
//  MyView.m
//  <16.0>图片和鼠标事件
//
//  Created by chen on 16/9/18.
//  Copyright © 2016年 tyrad. All rights reserved.
//

#import "MyView.h"

@implementation MyView

- (void)drawRect:(NSRect)dirtyRect {
    [super drawRect:dirtyRect];
    
    [[NSColor redColor]setFill];
    
    [NSBezierPath fillRect:self.bounds];
    
}



- (void)mouseDown:(NSEvent *)theEvent{
    NSLog(@"%s %ld",__func__, [theEvent modifierFlags]);
    
    if ([theEvent modifierFlags] & NSControlKeyMask) { //是“按位与”运算
        NSLog(@"按住了Control");  //  00001 & 00001 = YES   0010 & 0001 = NO
    }
    
    
}


- (void)rightMouseDown:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)otherMouseDown:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)mouseUp:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)rightMouseUp:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)otherMouseUp:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)mouseMoved:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)mouseDragged:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)scrollWheel:(NSEvent *)theEvent{ //中间滚轮滚动
    NSLog(@"%s",__func__);
}
- (void)rightMouseDragged:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)otherMouseDragged:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)mouseEntered:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)mouseExited:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)keyDown:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}
- (void)keyUp:(NSEvent *)theEvent{
    NSLog(@"%s",__func__);
}



@end
